import Vue from 'vue'
import Vuex from 'vuex'
import login from "@/store/modules/login";
import exam from "@/store/modules/exam";

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    httpHost: 'localhost',
    currentUser: JSON.parse(localStorage.getItem('current-user')),
  },
  getters: {},
  mutations: {
    SET_CURRENT_USER(state, value) {
      state.currentUser = value;
    },
  },
  actions: {
    modifyCurrentUser({commit}) {
      const user = JSON.parse(localStorage.getItem('current-user'));
      if (user) {
        commit('SET_CURRENT_USER', user);
      }
    },
  },
  modules: {
    login,
    exam,
  }
})
